package com.kylin.upms.biz.exception;


import com.kylin.common.result.ResEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionHandler {
    Logger logger = LoggerFactory.getLogger(this.getClass());

    @ResponseBody
    @org.springframework.web.bind.annotation.ExceptionHandler(value = Exception.class)
    public ResEntity excetion(Exception e){
        logger.error("操作失败",e);
        if (e instanceof  UserException){
            return ResEntity.error("用户操作失败",e.getMessage());
        }
        return ResEntity.error(e.getMessage());
    }
}
